<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
<title> <?php echo $item['name'] ? $item['name'].'的评论' : '输错了吧 :)'?> - <?=SITE_NAME?> </title>
<?php include VIEWS.'header.html'?>
<link rel="alternate" type="application/rss+xml" title="<?php echo $item['name'] ? $item['name'].'的评论' : ''?>" href="<?php echo $_servername?>/comments/<?php echo $item['id']?>/xml/" />

<script type="text/javascript">
<!--
var aa = ajaxStart();
var timer = null;

function newComment() {
    var f = $('newcommentform');
    $('submit').disabled = true;

    try {
        aa.call('/comments.php/<?php echo $item['id']?>/new', 'ajaxNewComment', newComment_result, 'iid=<?php echo $item['id']?>&'+ $('newcommentform').serialize());
        return false;
    } catch (e) {
        return true;
    }
}

function newComment_result(result) {
    var i;
    var d = $('updatemsg2');
    var err = 0;
    var ok = 0;
    try {
        var stat = result.result[0].data;
        switch(stat) {
            case 32: i = 'Email貌似不正确哦';err = 1;$('umail').focus();break;
            case 16: i = '姓名不能为空哟';err = 1;$('uname').focus();break;
            case 8: i = '你想说什么呀';err = 1;$('body').focus();break;
            case 128: i = '不要这么小气啊，再说点吧';err = 1;$('body').focus();break;
            case 4: i = '相同的话说一遍就行了喔';err = 1;$('body').focus();break;
            case 1:
                var node = result.cdata[0];
                var newhtml = '<div style="background-color:#F5F5F5;padding:4px;margin:6px;border:1px solid #EEEEEE"><b class="default">'+ node.uname[0].data +'<\/b>@'+ node.updated[0].data +'：<br />';
                newhtml += '<blockquote style="margin:0.6em">' + node.body[0].data + '<\/blockquote><\/div>';
                $('commentlist').innerHTML = newhtml + $('commentlist').innerHTML;
                ok = 1;
                $('body').value = '';
                $('rand_code').value = '';
                $('rand_code_img').src = '/rand_code.php?'+Date.parse(new Date());
                location.href='#top';
                break;
            case 256:  i = '您输入的验证数字不正确';err = 1;$('rand_code').focus();break;
            default:
                err = 1;i = '未知错误('+stat+')，请稍候再试';
        }
    } catch(e) {
        i = '服务器错误，请稍候再试';
        err = 1;
    }

    $('submit').disabled = false;
    if (i) {
        if (err==1) {
            d.style.backgroundColor= '#FF6600';
            d.style.color= '#FFF';
        } else {
            d.style.backgroundColor= '#DDF63E';
            d.style.color= '#000';
        }
        d.innerHTML = '&nbsp;&nbsp;&nbsp;' + i + '……';
        $('updatemsg2').show();
        new Effect.Round('div', 'updatemsg2');
        if (timer) window.clearTimeout(timer);
        timer = setTimeout( "$('updatemsg2').style.display='none';", 10000);
    }
    if (ok) $('updatemsg2').style.display='none';
}
//-->
</script>

<style>
b.master {
    color: #FF6240;
    padding: 2px;
}

b.guest {
    color: #999;
    padding: 2px;
}

b.default {
    color: #FF6240;
    padding: 2px;
}
</style>


<script type="text/javascript">
<!--
function open_topic() {$('c_text','newcomment').invoke('show');$('o_text').hide();location.href="#bottom";$('newcommentform').focusFirstElement()}
function close_topic() {$('c_text','newcomment').invoke('hide');$('o_text').show()}
<?php if($_GET['new']):?>window.onload=open_topic;<?php endif?>
//-->
</script>

</head>

<body>
<?php include VIEWS.'topbar.html'?>

<div id="content">

    <?php include VIEWS.'leftnav.html'?>

    <div id="right">
        <?php if ($item['id']):?><div style="float:right;margin-right:5px;font-size:12px"><a href="/<?php echo $item['id']?>">&#8249; 返回物品</a></div><?php endif?>

<?php if (!$item['name']):?>
    <?php include VIEWS.'sidesearch.html'?><h1>是不是输入错了 :)</h1><div class="errbox roundNormal">&nbsp;&nbsp;&nbsp;没有找到您要查看的物品评论，为何不看看我们有哪些 <a class="white" href="/whatnew">新品上架</a>!</div>
<?php else:?>
    <h1>对"<?php echo $item['name']?>"的评论 &nbsp; <a title="使用RSS订阅本页更新" tabindex="100" href="<?php echo $_servername?>/comments/<?php echo $item['id']?>/xml"><img width="30" height="14" src="/images/rss.gif" alt="RSS Feed" /></a></h1>
    <div style="float:right" class="px12">
    &#8250; <script type="text/javascript">needHelp();</script><noscript><a href="<?php echo $_servername?>/forum/service/?from=itemlist" target="_blank">需要帮助？</a></noscript>&nbsp;&nbsp;
    </div>
    <br />
    <br clear="all" />

    <div id="commentlist" class="px12">
    <?php if(count($list)>0) foreach($list as $c):$c_i++;?>
    <div style="background-color:#<?php echo $c_i%2==0 ? 'EEEEEE' : 'F5F5F5'?>;padding:4px;margin:6px;border:1px solid #EEEEEE">
        <img width="32" height="32" src="http://www.gravatar.com/avatar.php?gravatar_id=<?php echo md5($c['umail'])?>&amp;size=32&amp;default=<?php echo $_servername?>/images/icon/no-gravatar.gif" align="left" hspace="5" />
        <a name="c<?php echo $c['id']?>"></a><?php echo ($c['istb'] ? '<b class="default">TrackBack:</b>' : '') . ($c['url'] ? "<a href='{$c['url']}' target='_blank'>" : '') . '<b class="'. ($c['isadmin'] ? 'master' : ($c['uid'] ? 'default' : 'guest')) .'">'.($c['uname'] ? $c['uname'] : 'guest').'</b>' . ($c['url'] ? "</a>" : '') . '@'.date('y/m/d H:i', $c['updated'])?> (<a href="/comments/<?php echo $item['id'].'#c'.$c['id']?>" class="px12">永久链接</a></a>)<?php if($session['admin']):?>(<?php echo $c['umail']?>) (<a href="?remove=<?php echo $c['id']?>" class="px12" style="color:red">删除</a>)<?php endif?><br /><blockquote style="margin:0.6em"><?php echo nl2br($c['body'])?></blockquote></div>
    <?php endforeach?>
    </div>

    <?php if($page['next']):?><div style="text-align:right;margin:0.8em"><img alt="" src="/images/icon_arrow_red_right.gif" /><a class="px12" tabindex="3" href=<?php echo $page['url']?>p=<?php echo $page['next']?>>更早的评论</a></div><?php endif?>

    <a name="new"></a>
    <hr size="1" />
    <div class="updatemsg2" id="updatemsg2" style="font-weight:bold;background-color:#DDF63E;font-size:12px;width:90%;display:none;">&nbsp;</div><br clear="all">

    <div id="newcomment" style="margin-left:20px;font-size:12px;padding-top:10px;margin-top:10px">
    <form action="/comments.php/<?php echo $item['id']?>/new" method="post" id="newcommentform" onsubmit="javascript:return newComment();">

    <textarea class="px12" id="body" name="body" rows="10" cols="70" style="width:520px"><?php echo $comments['data']['body']?></textarea><br />
    <?php if(!$session['login']):?>
    姓名：<input class="px12" value="<?php echo $comments['data']['uname']?>" id="uname" size="10" maxlength="20" type="text" name="uname" /> &nbsp;
    Email：<input class="px12" value="<?php echo $comments['data']['umail']?>" id="umail" size="10" maxlength="60" type="text" name="umail" /> &nbsp;
    请输入右边的数字：<input id="rand_code" class="px12" type="text" name="rand_code" value="" size="8" maxlength="4" /> &nbsp; <img id="rand_code_img" src="/rand_code.php" align="absmiddle" /> <br />
    <?php endif?>
    <br /><br /><input tabindex="3" id="submit" type="submit" value="发表我的看法" class="bluebtn" /> &nbsp;
    <a href="/comments/all">看看别人的评论</a>
    <?php $_SESSION['_commentTime']=time(); //记录发表评论时的时间?>
    </form>
    </div>
<?php endif;?>

    </div>
</div>

<?php include VIEWS.'copyright.html'?>

</body>
</html>
